/*
 * Copyright (c) 2012 Johann Hanne
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef _UART_H
#define _UART_H

#define UART0_CT   0xff80 /* Control */
#define UART0_STS  0xff82 /* Status */
#define UART0_TD   0xff84 /* Transmit Data */
#define UART0_RD   0xff86 /* Receive Data */
#define UART0_BAUD 0xff88 /* Baud Rate Divisor */

#define UART1_CT   0xff10 /* Control */
#define UART1_STS  0xff12 /* Status */
#define UART1_TD   0xff14 /* Transmit Data */
#define UART1_RD   0xff16 /* Receive Data */
#define UART1_BAUD 0xff18 /* Baud Rate Divisor */

#define UART_CT_DMA_MASK  0xe000
#define UART_CT_RSIE      (1 << 12) /* Receive Status Interrupt Enable */
#define UART_CT_BRK       (1 << 11) /* Send Break */
#define UART_CT_TB8       (1 << 10) /* Transmit Bit 8 */
#define UART_CT_FC        (1 <<  9) /* Flow Control Enable */
#define UART_CT_TXIE      (1 <<  8) /* Transmitter Ready Interrupt Enable */
#define UART_CT_RXIE      (1 <<  7) /* Receive Data Ready Interrupt Enable */
#define UART_CT_TMODE     (1 <<  6) /* Transmit Mode (1 = transmit enable) */
#define UART_CT_RMODE     (1 <<  5) /* Receive Mode (1 = receive enable) */
#define UART_CT_EVN       (1 <<  4) /* Even Parity (1 = even parity, 0 = odd parity) */
#define UART_CT_PE        (1 <<  3) /* Parity Enable */
#define UART_CT_MODE_MASK 0x0007 

#define UART_STS_BRK1 (1 << 10) /* Long Break Detected */
#define UART_STS_BRK0 (1 <<  9) /* Short Break Detected */
#define UART_STS_RB8  (1 <<  8) /* Received Bit 8 */
#define UART_STS_RDR  (1 <<  7) /* Receive Data Ready */
#define UART_STS_THRE (1 <<  6) /* Transmit Holding Register Empty */
#define UART_STS_FER  (1 <<  5) /* Framing Error Detected */
#define UART_STS_OER  (1 <<  4) /* Overrun Error Detected */
#define UART_STS_PER  (1 <<  3) /* Parity Error Detected */
#define UART_STS_TEMT (1 <<  2) /* Transmitter Empty */
#define UART_STS_HS0  (1 <<  1) /* Handshake Signal 0 */

#endif /* _UART_H */
